﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

namespace YAMN_Cinemas.Presentation
{
    public partial class Admin_Create : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string username = txt_UserName.Text;
            string password = txt_Password.Text;
            string email = txt_Email.Text;
            string role = "Admin";
            MembershipCreateStatus status;
            MembershipUser user = Membership.CreateUser(username, password, email, null, null, true, out status);
            switch (status)
            {
                case MembershipCreateStatus.DuplicateUserName:
                    lbl_Status.Text = "Username already exists. Please enter a different user name.";
                    break;

                case MembershipCreateStatus.DuplicateEmail:
                    lbl_Status.Text = "A username for that e-mail address already exists. Please enter a different e-mail address.";
                    break;

                case MembershipCreateStatus.InvalidPassword:
                    lbl_Status.Text = "The password provided is invalid. Please enter a valid password value.";
                    break;

                case MembershipCreateStatus.InvalidEmail:
                    lbl_Status.Text = "The e-mail address provided is invalid. Please check the value and try again.";
                    break;

                case MembershipCreateStatus.InvalidAnswer:
                    lbl_Status.Text = "The password retrieval answer provided is invalid. Please check the value and try again.";
                    break;

                case MembershipCreateStatus.InvalidQuestion:
                    lbl_Status.Text = "The password retrieval question provided is invalid. Please check the value and try again.";
                    break;

                case MembershipCreateStatus.InvalidUserName:
                    lbl_Status.Text = "The user name provided is invalid. Please check the value and try again.";
                    break;

                case MembershipCreateStatus.ProviderError:
                    lbl_Status.Text = "The authentication provider lbl_Status.Text=ed an error. Please verify your entry and try again. If the problem persists, please contact your system administrator.";
                    break;

                case MembershipCreateStatus.UserRejected:
                    lbl_Status.Text = "The user creation request has been canceled. Please verify your entry and try again. If the problem persists, please contact your system administrator.";
                    break;
                case MembershipCreateStatus.Success:
                    Roles.AddUserToRole(username, role);
                    lbl_Status.Text = "You Account was created Successfully";
                    break;
            }
            
        }

        protected void Button2_Click(object sender, EventArgs e)
        {

            {


                Response.Redirect("");
            }
        }
    }
}